# -*- mode: python ; coding: utf-8 -*-

import sys
import os
from PyInstaller.utils.hooks import collect_data_files, collect_submodules

block_cipher = None

# 处理NumPy和其他复杂库的特殊情况
datas = collect_data_files('numpy', include_py_files=True)
datas.extend(collect_data_files('matplotlib', include_py_files=True))
hidden_imports = collect_submodules('numpy')
hidden_imports.extend(collect_submodules('matplotlib'))

# 添加其他必要的隐藏导入
hidden_imports.extend([
    'PyQt6',
    'PyQt6.QtWidgets',
    'PyQt6.QtCore',
    'PyQt6.QtGui',
    'sqlite3',
    'decimal',
    'hashlib',
    'time',
    'datetime',
    'json',
    'os',
    'sys',
    'matplotlib.backends.backend_agg',
    'matplotlib.figure',
    'matplotlib.axes',
    'matplotlib.patches',
    'matplotlib.path'
])

# 确保包含所有必要的数据文件
datas.extend([
    ('icon.ico', '.'),
    ('information_manager.db', '.')
])

a = Analysis(
    ['main.py'],
    pathex=['\\'],
    binaries=[],
    datas=datas,
    hiddenimports=hidden_imports,
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='小兔文档',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=['icon.ico'],
)